
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.alchemy.materials &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.alchemy.materials</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.alchemy.materials</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module provides various representations of transformed structures. A</span>
<span class="sd">TransformedStructure is a structure that has been modified by undergoing a</span>
<span class="sd">series of transformations.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">datetime</span>

<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MontyDecoder</span><span class="p">,</span> <span class="n">jsanitize</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.cif</span> <span class="kn">import</span> <span class="n">CifParser</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.inputs</span> <span class="kn">import</span> <span class="n">Poscar</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>

<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.sets</span> <span class="kn">import</span> <span class="n">MPRelaxSet</span>

<span class="kn">from</span> <span class="nn">warnings</span> <span class="kn">import</span> <span class="n">warn</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong, Will Richards&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2012, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;1.0&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;shyuep@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Mar 2, 2012&quot;</span>

<span class="n">dec</span> <span class="o">=</span> <span class="n">MontyDecoder</span><span class="p">()</span>


<div class="viewcode-block" id="TransformedStructure"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure">[docs]</a><span class="k">class</span> <span class="nc">TransformedStructure</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Container object for new structures that include history of</span>
<span class="sd">    transformations.</span>

<span class="sd">    Each transformed structure is made up of a sequence of structures with</span>
<span class="sd">    associated transformation history.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">transformations</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">other_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Initializes a transformed structure from a structure.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure</span>
<span class="sd">            transformations ([Transformations]): List of transformations to</span>
<span class="sd">                apply.</span>
<span class="sd">            history (list): Previous history.</span>
<span class="sd">            other_parameters (dict): Additional parameters to be added.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="o">=</span> <span class="n">history</span> <span class="ow">or</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">other_parameters</span> <span class="o">=</span> <span class="n">other_parameters</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_undone</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">transformations</span> <span class="o">=</span> <span class="n">transformations</span> <span class="ow">or</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">transformations</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">append_transformation</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>

<div class="viewcode-block" id="TransformedStructure.undo_last_change"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.undo_last_change">[docs]</a>    <span class="k">def</span> <span class="nf">undo_last_change</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Undo the last change in the TransformedStructure.</span>

<span class="sd">        Raises:</span>
<span class="sd">            IndexError: If already at the oldest change.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t undo. Already at oldest change.&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="s1">&#39;input_structure&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t undo. Latest history has no &quot;</span>
                             <span class="s2">&quot;input_structure&quot;</span><span class="p">)</span>
        <span class="n">h</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_undone</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">h</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">))</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">h</span><span class="p">[</span><span class="s2">&quot;input_structure&quot;</span><span class="p">]</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">s</span></div>

<div class="viewcode-block" id="TransformedStructure.redo_next_change"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.redo_next_change">[docs]</a>    <span class="k">def</span> <span class="nf">redo_next_change</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Redo the last undone change in the TransformedStructure.</span>

<span class="sd">        Raises:</span>
<span class="sd">            IndexError: If already at the latest change.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_undone</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t redo. Already at latest change.&quot;</span><span class="p">)</span>
        <span class="n">h</span><span class="p">,</span> <span class="n">s</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_undone</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">s</span></div>

    <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
        <span class="n">s</span> <span class="o">=</span> <span class="nb">object</span><span class="o">.</span><span class="fm">__getattribute__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;final_structure&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">)</span>

<div class="viewcode-block" id="TransformedStructure.append_transformation"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.append_transformation">[docs]</a>    <span class="k">def</span> <span class="nf">append_transformation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">transformation</span><span class="p">,</span> <span class="n">return_alternatives</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                              <span class="n">clear_redo</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Appends a transformation to the TransformedStructure.</span>

<span class="sd">        Args:</span>
<span class="sd">            transformation: Transformation to append</span>
<span class="sd">            return_alternatives: Whether to return alternative</span>
<span class="sd">                TransformedStructures for one-to-many transformations.</span>
<span class="sd">                return_alternatives can be a number, which stipulates the</span>
<span class="sd">                total number of structures to return.</span>
<span class="sd">            clear_redo: Boolean indicating whether to clear the redo list.</span>
<span class="sd">                By default, this is True, meaning any appends clears the</span>
<span class="sd">                history of undoing. However, when using append_transformation</span>
<span class="sd">                to do a redo, the redo list should not be cleared to allow</span>
<span class="sd">                multiple redos.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">clear_redo</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_undone</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">if</span> <span class="n">return_alternatives</span> <span class="ow">and</span> <span class="n">transformation</span><span class="o">.</span><span class="n">is_one_to_many</span><span class="p">:</span>
            <span class="n">ranked_list</span> <span class="o">=</span> <span class="n">transformation</span><span class="o">.</span><span class="n">apply_transformation</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">,</span> <span class="n">return_ranked_list</span><span class="o">=</span><span class="n">return_alternatives</span><span class="p">)</span>

            <span class="n">input_structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
            <span class="n">alts</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">ranked_list</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
                <span class="n">s</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;structure&quot;</span><span class="p">)</span>
                <span class="n">actual_transformation</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;transformation&quot;</span><span class="p">,</span> <span class="n">transformation</span><span class="p">)</span>
                <span class="n">hdict</span> <span class="o">=</span> <span class="n">actual_transformation</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
                <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;input_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">input_structure</span>
                <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;output_parameters&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">s</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
                <span class="n">d</span><span class="p">[</span><span class="s1">&#39;history&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hdict</span><span class="p">)</span>
                <span class="n">d</span><span class="p">[</span><span class="s1">&#39;final_structure&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
                <span class="n">alts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">TransformedStructure</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">))</span>

            <span class="n">x</span> <span class="o">=</span> <span class="n">ranked_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;structure&quot;</span><span class="p">)</span>
            <span class="n">actual_transformation</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;transformation&quot;</span><span class="p">,</span> <span class="n">transformation</span><span class="p">)</span>
            <span class="n">hdict</span> <span class="o">=</span> <span class="n">actual_transformation</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
            <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;input_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
            <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;output_parameters&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hdict</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">s</span>
            <span class="k">return</span> <span class="n">alts</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">transformation</span><span class="o">.</span><span class="n">apply_transformation</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">)</span>
            <span class="n">hdict</span> <span class="o">=</span> <span class="n">transformation</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
            <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;input_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
            <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;output_parameters&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hdict</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">=</span> <span class="n">s</span></div>

<div class="viewcode-block" id="TransformedStructure.append_filter"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.append_filter">[docs]</a>    <span class="k">def</span> <span class="nf">append_filter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure_filter</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Adds a filter.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure_filter (StructureFilter): A filter implementating the</span>
<span class="sd">                AbstractStructureFilter API. Tells transmuter waht structures</span>
<span class="sd">                to retain.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">hdict</span> <span class="o">=</span> <span class="n">structure_filter</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="n">hdict</span><span class="p">[</span><span class="s2">&quot;input_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hdict</span><span class="p">)</span></div>

<div class="viewcode-block" id="TransformedStructure.extend_transformations"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.extend_transformations">[docs]</a>    <span class="k">def</span> <span class="nf">extend_transformations</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">transformations</span><span class="p">,</span>
                               <span class="n">return_alternatives</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Extends a sequence of transformations to the TransformedStructure.</span>

<span class="sd">        Args:</span>
<span class="sd">            transformations: Sequence of Transformations</span>
<span class="sd">            return_alternatives: Whether to return alternative</span>
<span class="sd">                TransformedStructures for one-to-many transformations.</span>
<span class="sd">                return_alternatives can be a number, which stipulates the</span>
<span class="sd">                total number of structures to return.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">transformations</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">append_transformation</span><span class="p">(</span><span class="n">t</span><span class="p">,</span>
                                       <span class="n">return_alternatives</span><span class="o">=</span><span class="n">return_alternatives</span><span class="p">)</span></div>

<div class="viewcode-block" id="TransformedStructure.get_vasp_input"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.get_vasp_input">[docs]</a>    <span class="k">def</span> <span class="nf">get_vasp_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vasp_input_set</span><span class="o">=</span><span class="n">MPRelaxSet</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns VASP input as a dict of vasp objects.</span>

<span class="sd">        Args:</span>
<span class="sd">            vasp_input_set (pymatgen.io.vaspio_set.VaspInputSet): input set</span>
<span class="sd">                to create vasp input files from structures</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="n">vasp_input_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">get_vasp_input</span><span class="p">()</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;transformations.json&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">as_dict</span><span class="p">())</span>
        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="TransformedStructure.write_vasp_input"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.write_vasp_input">[docs]</a>    <span class="k">def</span> <span class="nf">write_vasp_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vasp_input_set</span><span class="o">=</span><span class="n">MPRelaxSet</span><span class="p">,</span> <span class="n">output_dir</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">,</span>
                         <span class="n">create_directory</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Writes VASP input to an output_dir.</span>

<span class="sd">        Args:</span>
<span class="sd">            vasp_input_set:</span>
<span class="sd">                pymatgen.io.vaspio_set.VaspInputSet like object that creates</span>
<span class="sd">                vasp input files from structures</span>
<span class="sd">            output_dir: Directory to output files</span>
<span class="sd">            create_directory: Create the directory if not present. Defaults to</span>
<span class="sd">                True.</span>
<span class="sd">            **kwargs: All keyword args supported by the VASP input set.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">vasp_input_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">write_input</span><span class="p">(</span>
            <span class="n">output_dir</span><span class="p">,</span> <span class="n">make_dir_if_not_present</span><span class="o">=</span><span class="n">create_directory</span><span class="p">)</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output_dir</span><span class="p">,</span> <span class="s2">&quot;transformations.json&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
            <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(),</span> <span class="n">fp</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">output</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;Current structure&quot;</span><span class="p">,</span> <span class="s2">&quot;------------&quot;</span><span class="p">,</span>
                  <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">),</span>
                  <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">History&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;------------&quot;</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
            <span class="n">h</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;input_structure&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">h</span><span class="p">))</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Other parameters&quot;</span><span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;------------&quot;</span><span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">other_parameters</span><span class="p">))</span>
        <span class="k">return</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>

<div class="viewcode-block" id="TransformedStructure.set_parameter"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.set_parameter">[docs]</a>    <span class="k">def</span> <span class="nf">set_parameter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set a parameter</span>

<span class="sd">        :param key: The string key</span>
<span class="sd">        :param value: The value.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">other_parameters</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">was_modified</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Boolean describing whether the last transformation on the structure</span>
<span class="sd">        made any alterations to it one example of when this would return false</span>
<span class="sd">        is in the case of performing a substitution transformation on the</span>
<span class="sd">        structure when the specie to replace isn&#39;t in the structure.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">structures</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Copy of all structures in the TransformedStructure. A</span>
<span class="sd">        structure is stored after every single transformation.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">hstructs</span> <span class="o">=</span> <span class="p">[</span><span class="n">Structure</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="s1">&#39;input_structure&#39;</span><span class="p">])</span>
                    <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span> <span class="k">if</span> <span class="s1">&#39;input_structure&#39;</span> <span class="ow">in</span> <span class="n">s</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">hstructs</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">]</span>

<div class="viewcode-block" id="TransformedStructure.from_cif_string"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.from_cif_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_cif_string</span><span class="p">(</span><span class="n">cif_string</span><span class="p">,</span> <span class="n">transformations</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">primitive</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                        <span class="n">occupancy_tolerance</span><span class="o">=</span><span class="mf">1.</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generates TransformedStructure from a cif string.</span>

<span class="sd">        Args:</span>
<span class="sd">            cif_string (str): Input cif string. Should contain only one</span>
<span class="sd">                structure. For cifs containing multiple structures, please use</span>
<span class="sd">                CifTransmuter.</span>
<span class="sd">            transformations ([Transformations]): Sequence of transformations</span>
<span class="sd">                to be applied to the input structure.</span>
<span class="sd">            primitive (bool): Option to set if the primitive cell should be</span>
<span class="sd">                extracted. Defaults to True. However, there are certain</span>
<span class="sd">                instances where you might want to use a non-primitive cell,</span>
<span class="sd">                e.g., if you are trying to generate all possible orderings of</span>
<span class="sd">                partial removals or order a disordered structure.</span>
<span class="sd">            occupancy_tolerance (float): If total occupancy of a site is</span>
<span class="sd">                between 1 and occupancy_tolerance, the occupancies will be</span>
<span class="sd">                scaled down to 1.</span>

<span class="sd">        Returns:</span>
<span class="sd">            TransformedStructure</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">parser</span> <span class="o">=</span> <span class="n">CifParser</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">cif_string</span><span class="p">,</span> <span class="n">occupancy_tolerance</span><span class="p">)</span>
        <span class="n">raw_string</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;&#39;&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">cif_string</span><span class="p">)</span>
        <span class="n">cif_dict</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="n">cif_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">cif_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">get_structures</span><span class="p">(</span><span class="n">primitive</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">partial_cif</span> <span class="o">=</span> <span class="n">cif_dict</span><span class="p">[</span><span class="n">cif_keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
        <span class="k">if</span> <span class="s2">&quot;_database_code_ICSD&quot;</span> <span class="ow">in</span> <span class="n">partial_cif</span><span class="p">:</span>
            <span class="n">source</span> <span class="o">=</span> <span class="n">partial_cif</span><span class="p">[</span><span class="s2">&quot;_database_code_ICSD&quot;</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;-ICSD&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">source</span> <span class="o">=</span> <span class="s2">&quot;uploaded cif&quot;</span>
        <span class="n">source_info</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="n">source</span><span class="p">,</span>
                       <span class="s2">&quot;datetime&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()),</span>
                       <span class="s2">&quot;original_file&quot;</span><span class="p">:</span> <span class="n">raw_string</span><span class="p">,</span>
                       <span class="s2">&quot;cif_data&quot;</span><span class="p">:</span> <span class="n">cif_dict</span><span class="p">[</span><span class="n">cif_keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]}</span>
        <span class="k">return</span> <span class="n">TransformedStructure</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">transformations</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="p">[</span><span class="n">source_info</span><span class="p">])</span></div>

<div class="viewcode-block" id="TransformedStructure.from_poscar_string"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.from_poscar_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_poscar_string</span><span class="p">(</span><span class="n">poscar_string</span><span class="p">,</span> <span class="n">transformations</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generates TransformedStructure from a poscar string.</span>

<span class="sd">        Args:</span>
<span class="sd">            poscar_string (str): Input POSCAR string.</span>
<span class="sd">            transformations ([Transformations]): Sequence of transformations</span>
<span class="sd">                to be applied to the input structure.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">Poscar</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">poscar_string</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">true_names</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Transformation can be craeted only from POSCAR &quot;</span>
                             <span class="s2">&quot;strings with proper VASP5 element symbols.&quot;</span><span class="p">)</span>
        <span class="n">raw_string</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;&#39;&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">poscar_string</span><span class="p">)</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">structure</span>
        <span class="n">source_info</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span>
                       <span class="s2">&quot;datetime&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()),</span>
                       <span class="s2">&quot;original_file&quot;</span><span class="p">:</span> <span class="n">raw_string</span><span class="p">}</span>
        <span class="k">return</span> <span class="n">TransformedStructure</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">transformations</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="p">[</span><span class="n">source_info</span><span class="p">])</span></div>

<div class="viewcode-block" id="TransformedStructure.as_dict"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Dict representation of the TransformedStructure.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@module&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@class&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;history&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">jsanitize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">)</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;version&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">__version__</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;last_modified&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">())</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;other_parameters&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">jsanitize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">other_parameters</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="TransformedStructure.from_dict"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Creates a TransformedStructure from a dict.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;history&quot;</span><span class="p">],</span>
                   <span class="n">other_parameters</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;other_parameters&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span></div>

<div class="viewcode-block" id="TransformedStructure.to_snl"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.to_snl">[docs]</a>    <span class="k">def</span> <span class="nf">to_snl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">authors</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate SNL from TransformedStructure.</span>

<span class="sd">        :param authors: List of authors</span>
<span class="sd">        :param **kwargs: All kwargs supported by StructureNL.</span>
<span class="sd">        :return: StructureNL</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">other_parameters</span><span class="p">:</span>
            <span class="n">warn</span><span class="p">(</span><span class="s1">&#39;Data in TransformedStructure.other_parameters discarded &#39;</span>
                 <span class="s1">&#39;during type conversion to SNL&#39;</span><span class="p">)</span>
        <span class="n">hist</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
            <span class="n">snl_metadata</span> <span class="o">=</span> <span class="n">h</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;_snl&#39;</span><span class="p">,</span> <span class="p">{})</span>
            <span class="n">hist</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="n">snl_metadata</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;pymatgen&#39;</span><span class="p">),</span>
                         <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="n">snl_metadata</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span>
                             <span class="s1">&#39;url&#39;</span><span class="p">,</span> <span class="s1">&#39;http://pypi.python.org/pypi/pymatgen&#39;</span><span class="p">),</span>
                         <span class="s1">&#39;description&#39;</span><span class="p">:</span> <span class="n">h</span><span class="p">})</span>
        <span class="kn">from</span> <span class="nn">pymatgen.util.provenance</span> <span class="kn">import</span> <span class="n">StructureNL</span>
        <span class="k">return</span> <span class="n">StructureNL</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">,</span> <span class="n">authors</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="n">hist</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="TransformedStructure.from_snl"><a class="viewcode-back" href="../../../pymatgen.alchemy.materials.html#pymatgen.alchemy.materials.TransformedStructure.from_snl">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_snl</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">snl</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Create TransformedStructure from SNL.</span>

<span class="sd">        Args:</span>
<span class="sd">            snl (StructureNL): Starting snl</span>

<span class="sd">        Returns:</span>
<span class="sd">            TransformedStructure</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">hist</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">snl</span><span class="o">.</span><span class="n">history</span><span class="p">:</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">h</span><span class="o">.</span><span class="n">description</span>
            <span class="n">d</span><span class="p">[</span><span class="s1">&#39;_snl&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="n">h</span><span class="o">.</span><span class="n">url</span><span class="p">,</span> <span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="n">h</span><span class="o">.</span><span class="n">name</span><span class="p">}</span>
            <span class="n">hist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">snl</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="n">history</span><span class="o">=</span><span class="n">hist</span><span class="p">)</span></div></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.alchemy.materials</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>